package com.sks.bean.pojo;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Where;

import com.sks.bean.privilege.Employee;



/**
 * @ClassName News. 
 * @author yjy
 * @todate 2011-11-7
 */
@Entity 
public class News implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	// Fields
	
	public static String NEWS_STATUS_NONE_PUBLISH = "nonePublish";
	
	public static String NEWS_STATUS_PUBLISHED = "published";
	
	public static String NEWS_STATUS_INVALIDATE = "invalidate";

	private Integer newsId;
	private Feature feature;
/*	private Employee lastUpdateEmployee;*/
	private Employee createEmployee;
	private Date createTime;
	private String title;
	private String writer;
	private Date publishTime;
	private Date lastUpdateTime;
	private String content;
	private String section;
	private String source;
	private String link;
	private String status;
	private Integer click;
	private String remark;
	private Integer featureId;
	private String lastUpdateUserId;
	private String createUserId;
/*	private Set<Feature> feature = new HashSet<Feature>(0);*/
	
	private List<AuditHistory> auditHistory = new ArrayList<AuditHistory>(0);
	
	// Constructors

	/** default constructor */
	public News() {
	}

	/** minimal constructor */
	public News(Feature feature, Date createTime, String title,
			Date lastUpdateTime, String content, String status) {
		this.feature = feature;
		this.createTime = createTime;
		this.title = title;
		this.lastUpdateTime = lastUpdateTime;
		this.content = content;
		this.status = status;
	}

	/** full constructor */
	public News(Feature feature, Employee sysUserByLastUpdateUserId,
			Employee sysUserByCreateUserId, Date createTime, String title,
			String writer, Date publishTime, Date lastUpdateTime,
			String content, String source, String link, String status,
			Integer click, String remark, String createUserId, String lastUpdateUserId) {
		this.feature = feature;
/*		this.lastUpdateEmployee = sysUserByLastUpdateUserId;*/
		this.createEmployee = sysUserByCreateUserId;
		this.createTime = createTime;
		this.title = title;
		this.writer = writer;
		this.publishTime = publishTime;
		this.lastUpdateTime = lastUpdateTime;
		this.content = content;
		this.source = source;
		this.link = link;
		this.status = status;
		this.click = click;
		this.remark = remark;
		this.createUserId=createUserId;
		this.lastUpdateUserId=lastUpdateUserId;
		
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name="newsId",unique = true, nullable = false)
	public Integer getNewsId() {
		return this.newsId;
	}

	public void setNewsId(Integer newsId) {
		this.newsId = newsId;
	}


/*	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "News")
	public Feature getFeature() {
		return (Feature) this.feature;
	}

	@SuppressWarnings("unchecked")
	public void setFeature(Integer feature) {
		this.featureId =  feature;
	}*/


	@Temporal(TemporalType.TIMESTAMP) 
	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(length=64, unique = true, nullable = false, insertable = true, updatable = true)
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(length=40)
	public String getWriter() {
		return this.writer;
	}

	public void setWriter(String writer) {
		this.writer = writer;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	public Date getPublishTime() {
		return this.publishTime;
	}
	
	public void setPublishTime(Date publishTime) {
		this.publishTime = publishTime;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	public Date getLastUpdateTime() {
		return this.lastUpdateTime;
	}

	public void setLastUpdateTime(Date lastUpdateTime) {
		this.lastUpdateTime = lastUpdateTime;
	}

	@Column(nullable=false,length=99999999)
	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}
	
	@Column(nullable=false,length=500)
	public String getSection() {
		return this.section;
	}

	public void setSection(String section) {
		this.section = section;
	}

	@Column(length=100)
	public String getSource() {
		return this.source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	@Column(length=300)
	public String getLink() {
		return this.link;
	}

	public void setLink(String link) {
		this.link = link;
	}

	@Column(length=11)
	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Column(length=11)
	public Integer getClick() {
		return this.click;
	}

	public void setClick(Integer click) {
		this.click = click;
	}
	
	@Column(length=200)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	
/*	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="lastUpdateUserId",unique = true, nullable = true, insertable = true, updatable = true)
	public Employee getLastUpdateEmployee() {
		return lastUpdateEmployee;
	}

	public void setLastUpdateEmployee(Employee lastUpdateEmployee) {
		this.lastUpdateEmployee = lastUpdateEmployee;
	}*/


	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="createUserId",unique = true, nullable = false, insertable = true, updatable = true)
	public Employee getCreateEmployee() {
		return createEmployee;
	}

	public void setCreateEmployee(Employee createEmployee) {
		this.createEmployee = createEmployee;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="featureId",unique = true, nullable = false, insertable = true, updatable = true)
	public Feature getFeature() {
		return feature;
	}

	public void setFeature(Feature feature) {
		this.feature = feature;
	}

	@Transient
	public Integer getFeatureId() {
		return featureId;
	}

	public void setFeatureId(Integer featureId) {
		this.featureId = featureId;
	}

	@Column(length=50)
	public String getLastUpdateUserId() {
		return lastUpdateUserId;
	}

	public void setLastUpdateUserId(String lastUpdateUserId) {
		this.lastUpdateUserId = lastUpdateUserId;
	}

	@Transient
	public String getCreateUserId() {
		return createUserId;
	}

	public void setCreateUserId(String createUserId) {
		this.createUserId = createUserId;
	}

	@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "news")
	@Where(clause="objType = \"news\"")
	public List<AuditHistory> getAuditHistory() {
		return auditHistory;
	}

	public void setAuditHistory(List<AuditHistory> auditHistory) {
		this.auditHistory = auditHistory;
	}
	
}